home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 98 / Skunkware 98.iso / src / mail / pine3.96.tar.gz / pine3.96.tar / pine3.96 / imap / ANSI / c-client / imap2.h < prev    next >
C/C++ Source or Header  |  1995-09-07  |  9KB  |  230 lines

  1. /*
  2.  * Program:    Interactive Mail Access Protocol 2 (IMAP2) routines
  3.  *
  4.  * Author:    Mark Crispin
  5.  *        Networks and Distributed Computing
  6.  *        Computing & Communications
  7.  *        University of Washington
  8.  *        Administration Building, AG-44
  9.  *        Seattle, WA  98195
  10.  *        Internet: MRC@CAC.Washington.EDU
  11.  *
  12.  * Date:    15 June 1988
  13.  * Last Edited:    6 September 1995
  14.  *
  15.  * Sponsorship:    The original version of this work was developed in the
  16.  *        Symbolic Systems Resources Group of the Knowledge Systems
  17.  *        Laboratory at Stanford University in 1987-88, and was funded
  18.  *        by the Biomedical Research Technology Program of the National
  19.  *        Institutes of Health under grant number RR-00785.
  20.  *
  21.  * Original version Copyright 1988 by The Leland Stanford Junior University
  22.  * Copyright 1995 by the University of Washington
  23.  *
  24.  *  Permission to use, copy, modify, and distribute this software and its
  25.  * documentation for any purpose and without fee is hereby granted, provided
  26.  * that the above copyright notices appear in all copies and that both the
  27.  * above copyright notices and this permission notice appear in supporting
  28.  * documentation, and that the name of the University of Washington or The
  29.  * Leland Stanford Junior University not be used in advertising or publicity
  30.  * pertaining to distribution of the software without specific, written prior
  31.  * permission.  This software is made available "as is", and
  32.  * THE UNIVERSITY OF WASHINGTON AND THE LELAND STANFORD JUNIOR UNIVERSITY
  33.  * DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, WITH REGARD TO THIS SOFTWARE,
  34.  * INCLUDING WITHOUT LIMITATION ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
  35.  * FITNESS FOR A PARTICULAR PURPOSE, AND IN NO EVENT SHALL THE UNIVERSITY OF
  36.  * WASHINGTON OR THE LELAND STANFORD JUNIOR UNIVERSITY BE LIABLE FOR ANY
  37.  * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
  38.  * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
  39.  * CONTRACT, TORT (INCLUDING NEGLIGENCE) OR STRICT LIABILITY, ARISING OUT OF
  40.  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  41.  *
  42.  */
  43.  
  44. /* IMAP2 specific definitions */
  45.  
  46. /* Parameters */
  47.  
  48. #define MAXLOGINTRIALS 3    /* maximum number of login trials */
  49. #define MAPLOOKAHEAD 20        /* fetch lookahead */
  50. #define IMAPTCPPORT (long) 143    /* assigned TCP contact port */
  51.  
  52.  
  53. /* Parsed reply message from imap_reply */
  54.  
  55. typedef struct imap_parsed_reply {
  56.   char *line;            /* original reply string pointer */
  57.   char *tag;            /* command tag this reply is for */
  58.   char *key;            /* reply keyword */
  59.   char *text;            /* subsequent text */
  60. } IMAPPARSEDREPLY;
  61.  
  62.  
  63. #define IMAPTMPLEN 16*MAILTMPLEN
  64.  
  65. /* IMAP2 I/O stream local data */
  66.     
  67. typedef struct imap_local {
  68.   void *tcpstream;        /* TCP I/O stream */
  69.   IMAPPARSEDREPLY reply;    /* last parsed reply */
  70.   unsigned int use_body : 1;    /* server supports structured bodies */
  71.   unsigned int use_find : 1;    /* server supports FIND command */
  72.   unsigned int use_bboard : 1;    /* server supports BBOARD command */
  73.   unsigned int use_purge : 1;    /* server supports PURGE command */
  74.   char *user;            /* logged in user name */
  75.   char *prefix;            /* find prefix */
  76.   char tmp[IMAPTMPLEN];        /* temporary buffer */
  77. } IMAPLOCAL;
  78.  
  79.  
  80. /* Convenient access to local data */
  81.  
  82. #define LOCAL ((IMAPLOCAL *) stream->local)
  83.  
  84. /* Coddle certain compilers' 6-character symbol limitation */
  85.  
  86. #ifdef __COMPILER_KCC__
  87. #define map_valid ivalid
  88. #define map_parameters iparam
  89. #define map_find ifind
  90. #define map_find_bboards ifindb
  91. #define map_find_all ifnda
  92. #define map_find_all_bboards ifndab
  93. #define map_subscribe isubsc
  94. #define map_unsubscribe iunsub
  95. #define map_subscribe_bboard isubbb
  96. #define map_unsubscribe_bboard iusbbb
  97. #define map_create icreat
  98. #define map_delete idelet
  99. #define map_rename irenam
  100. #define map_manage imanag
  101. #define map_open iopen
  102. #define map_close iclose
  103. #define map_fetchfast iffast
  104. #define map_fetchflags ifflags
  105. #define map_fetchstructure ifenv
  106. #define map_fetchheader ifhead
  107. #define map_fetchtext iftext
  108. #define map_fetchbody ifbody
  109. #define map_setflag isflag
  110. #define map_clearflag icflag
  111. #define map_search isearch
  112. #define map_ping iping
  113. #define map_check icheck
  114. #define map_expunge iexpun
  115. #define map_copy icopy
  116. #define map_move imove
  117. #define map_append iappnd
  118. #define map_gc igc
  119. #define map_gc_body igcb
  120.  
  121. #define imap_host imhost
  122. #define imap_port import
  123. #define imap_user imuser
  124. #define imap_select imsele
  125. #define imap_send imsend
  126. #define imap_soutr imsotr
  127. #define imap_reply imrepl
  128. #define imap_parse_reply imprep
  129. #define imap_fake imfake
  130. #define imap_OK imok
  131. #define imap_parse_unsolicited impuns
  132. #define imap_parse_flaglst impflg
  133. #define imap_searched imsear
  134. #define imap_expunged imexpu
  135. #define imap_parse_data impdat
  136. #define imap_parse_prop imppro
  137. #define imap_parse_envelope impenv
  138. #define imap_parse_adrlist impadl
  139. #define imap_parse_address impadr
  140. #define imap_parse_flags impfla
  141. #define imap_parse_sys_flag impsfl
  142. #define imap_parse_user_flag impufl
  143. #define imap_parse_string impstr
  144. #define imap_parse_number impnum
  145. #define imap_parse_enclist impecl
  146. #define imap_parse_encoding impenc
  147. #define imap_parse_body impbod
  148. #define imap_parse_body_structure impbst
  149. #endif
  150.  
  151. /* imap_send() helper macros */
  152.  
  153. #define imap_send0(s,c) imap_send (s,c,NIL,NIL,NIL,NIL,NIL,NIL)
  154. #define imap_send1(s,c,a1) imap_send (s,c,NIL,a1,NIL,NIL,NIL,NIL)
  155. #define imap_send2(s,c,a1,a2) imap_send (s,c,NIL,a1,a2,NIL,NIL,NIL)
  156. #define imap_send2f(s,c,a1,a2,a3) imap_send (s,c,NIL,a1,a2,a3,NIL,NIL)
  157. #define imap_sendq1(s,c,a1) imap_send (s,c,a1,NIL,NIL,NIL,NIL,NIL)
  158. #define imap_sendq2(s,c,a1,a2) imap_send (s,c,a1,NIL,NIL,NIL,a2,NIL)
  159.  
  160. /* Function prototypes */
  161.  
  162. DRIVER *map_valid (char *name);
  163. void *map_parameters (long function,void *value);
  164. void map_find (MAILSTREAM *stream,char *pat);
  165. void map_find_bboards (MAILSTREAM *stream,char *pat);
  166. void map_find_all (MAILSTREAM *stream,char *pat);
  167. void map_find_all_bboards (MAILSTREAM *stream,char *pat);
  168. long map_subscribe (MAILSTREAM *stream,char *mailbox);
  169. long map_unsubscribe (MAILSTREAM *stream,char *mailbox);
  170. long map_subscribe_bboard (MAILSTREAM *stream,char *mailbox);
  171. long map_unsubscribe_bboard (MAILSTREAM *stream,char *mailbox);
  172. long map_create (MAILSTREAM *stream,char *mailbox);
  173. long map_delete (MAILSTREAM *stream,char *mailbox);
  174. long map_rename (MAILSTREAM *stream,char *old,char *new);
  175. long map_manage (MAILSTREAM *stream,char *mailbox,char *command,char *arg2);
  176. MAILSTREAM *map_open (MAILSTREAM *stream);
  177. void map_close (MAILSTREAM *stream);
  178. void map_fetchfast (MAILSTREAM *stream,char *sequence);
  179. void map_fetchflags (MAILSTREAM *stream,char *sequence);
  180. ENVELOPE *map_fetchstructure (MAILSTREAM *stream,long msgno,BODY **body);
  181. char *map_fetchheader (MAILSTREAM *stream,long msgno);
  182. char *map_fetchtext (MAILSTREAM *stream,long msgno);
  183. char *map_fetchbody (MAILSTREAM *stream,long m,char *sec,unsigned long *len);
  184. void map_setflag (MAILSTREAM *stream,char *seq,char *flag);
  185. void map_clearflag (MAILSTREAM *stream,char *seq,char *flag);
  186. void map_search (MAILSTREAM *stream,char *criteria);
  187. long map_ping (MAILSTREAM *stream);
  188. void map_check (MAILSTREAM *stream);
  189. void map_expunge (MAILSTREAM *stream);
  190. long map_copy (MAILSTREAM *stream,char *sequence,char *mailbox);
  191. long map_move (MAILSTREAM *stream,char *sequence,char *mailbox);
  192. long map_append (MAILSTREAM *stream,char *mailbox,char *flags,char *date,
  193.          STRING *msg);
  194. void map_gc (MAILSTREAM *stream,long gcflags);
  195. void map_gc_body (BODY *body);
  196.  
  197. char *imap_host (MAILSTREAM *stream);
  198. long imap_port (MAILSTREAM *stream);
  199. char *imap_user (MAILSTREAM *stream);
  200. IMAPPARSEDREPLY *imap_send (MAILSTREAM *stream,char *cmd,char *a1,char *a2,
  201.                 char *a3,char *a4,char *a5,STRING *a6);
  202. IMAPPARSEDREPLY *imap_soutr (MAILSTREAM *stream,char *tag,char *string);
  203. IMAPPARSEDREPLY *imap_reply (MAILSTREAM *stream,char *tag);
  204. IMAPPARSEDREPLY *imap_parse_reply (MAILSTREAM *stream,char *text);
  205. IMAPPARSEDREPLY *imap_fake (MAILSTREAM *stream,char *tag,char *text);
  206. long imap_OK (MAILSTREAM *stream,IMAPPARSEDREPLY *reply);
  207. void imap_parse_unsolicited (MAILSTREAM *stream,IMAPPARSEDREPLY *reply);
  208. void imap_parse_flaglst (MAILSTREAM *stream,IMAPPARSEDREPLY *reply);
  209. void imap_searched (MAILSTREAM *stream,char *text);
  210. void imap_expunged (MAILSTREAM *stream,long msgno);
  211. void imap_parse_data (MAILSTREAM *stream,long msgno,char *text,
  212.               IMAPPARSEDREPLY *reply);
  213. void imap_parse_prop (MAILSTREAM *stream,MESSAGECACHE *elt,char *prop,
  214.               char **txtptr,IMAPPARSEDREPLY *reply);
  215. void imap_parse_envelope (MAILSTREAM *stream,ENVELOPE **env,char **txtptr,
  216.               IMAPPARSEDREPLY *reply);
  217. ADDRESS *imap_parse_adrlist (MAILSTREAM *stream,char **txtptr,
  218.                  IMAPPARSEDREPLY *reply);
  219. ADDRESS *imap_parse_address (MAILSTREAM *stream,char **txtptr,
  220.                  IMAPPARSEDREPLY *reply);
  221. void imap_parse_flags (MAILSTREAM *stream,MESSAGECACHE *elt,char **txtptr);
  222. void imap_parse_user_flag (MAILSTREAM *stream,MESSAGECACHE *elt,char *flag);
  223. char *imap_parse_string (MAILSTREAM *stream,char **txtptr,
  224.              IMAPPARSEDREPLY *reply,long special);
  225. unsigned long imap_parse_number (MAILSTREAM *stream,char **txtptr);
  226. void imap_parse_body (MAILSTREAM *stream,long msgno,BODY **body,char *seg,
  227.               char **txtptr,IMAPPARSEDREPLY *reply);
  228. void imap_parse_body_structure (MAILSTREAM *stream,BODY *body,char **txtptr,
  229.                 IMAPPARSEDREPLY *reply);
  230.